<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page import="sfmc.biz.vo.Sfmc_TB_EMPLOYEE"%>
<%
String empList = (String)request.getAttribute("empList");
Sfmc_TB_EMPLOYEE empdata = (Sfmc_TB_EMPLOYEE)request.getAttribute("empdata");
%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8" />
<meta http-equiv="Cache-Control" content="No-Cache" />
<meta http-equiv="Pragma" content="No-Cache" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>담당자 등록</title>
<link rel="stylesheet" type="text/css" href="/resources/theme/metro-blue/easyui.css" />
<link rel="stylesheet" type="text/css" href="/resources/theme/icon.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/ui_custom.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/design.css" />
<link rel="stylesheet" type="text/css" href="/resources/css/form.css" />
<!--[if lt IE 9]>
	<script type="text/javascript" src="/resources/js/html5.js" /></script>
<![endif]-->
<script type="text/javascript" src="/resources/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/resources/js/jquery.jclock.js"></script>
<script type="text/javascript" src="/resources/js/common.js" /></script>
<script type="text/javascript" src="/resources/js/is.validate.js" /></script>

<script type="text/javascript" language="javascript">
function getListEnter(){
	if(event.keyCode != 13){
		return false;
	}else{
		getList();
	}
}
function getList(){
	document.form.target = "_self";
	document.form.action="/emp_list.do";
	document.form.submit();
}
function getExcel(){
	document.form.target = "_self";
	document.form.action="/emp_excel.do";
	document.form.submit();
}
function clearData(){
	document.form.dataEmpIdx.value = 0;
	document.form.dataEmpName.value = "";
}
function saveData(){
	
	if(validate()){
		document.form.target = "behindFrame";
		document.form.action="/emp_save.do";
		document.form.submit();	
	}	
}
function deleteData(){
	if(confirm("["+document.form.dataEmpName.value + "]을(를) 삭제하시겠습니까?")){
		document.form.target = "behindFrame";
		document.form.action="/emp_delete.do";
		document.form.submit();	
	}
}

function reload(returnVal, type){
	
	if(returnVal==-1){
		switch(type){
		case "C": 
			alert("저장중 에러가 발생 하였습니다.");
			break;
		case "U": 
			alert("수정중 에러가 발생 하였습니다.");
			break;
		case "D": 
			alert("삭제중 에러가 발생 하였습니다.");
			break;
		}
	}else{
		switch(type){
		case "C": 
			alert("저장되었습니다.");
			break;
		case "U": 
			alert("수정되었습니다.");
			break;
		case "D": 
			alert("삭제되었습니다.");
			break;
		}
		
		document.form.target = "_self";
		document.form.action="/emp_list.do";
		document.form.submit();	
	}
}

function validate(){
	
	var form = document.form;
	if(form.dataEmpName.value == ""){
		alert("사원명을 입력하세요.");
		form.dataEmpName.focus();
		return false;
	}else{
		if(!isValideBytes(form.dataEmpName, "사원명")){
			return false;
		}
	}
	
	return true;
}
</script>
</head>
	
<body class="pop easyui-layout">
<form method="POST" name="form">
<iframe id="behindFrame" name="behindFrame"></iframe>
<input type="hidden" name="searchEmpIdx" value="<%=empdata.getSearchEmpIdx()%>"/>
<input type="hidden" name="dataEmpIdx" value="0"/>
	<div data-options="region:'center',border:false,iconCls:'icon-head02',title:'담당자 등록'">	
	
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false">
				<div class="easyui-panel bb0" data-options="border:false,fit:true">
					<table id="grid_emp" class="easyui-datagrid"></table>
							
					<div id="tb_emp" class="datagrid-toolbar wrap_tbl_toolbar">	
						<table class="tbl_inner">	
							<colgroup>
								<col width="60px">
								<col width="80px">
							</colgroup>
							<tr>
								<th>사원명</th>
								<td class="formText"><input type="text" name="searchEmpName" value="<%=empdata.getSearchEmpName()%>" onKeyPress="getListEnter();"/></td>
								<td><a href="javascript:getList();"class="easyui-linkbutton" data-options="iconCls:'icon-search'">조회</a>
								<a href="javascript:getExcel();" class="easyui-linkbutton" data-options="iconCls:'icon-excel'">엑셀저장</a>
							</tr>
							
						</table>
					</div>
				</div>
			</div>
			<div data-options="region:'south',border:false">
				<div class="easyui-panel combobox-item-selected padding5" data-options="fit:true" style="height:80px;overflow:hidden">
					<div class="wrap_tbl_inner">	
						<table class="tbl_inner">	
							<colgroup>
								<col width="55px">
								<col>
							</colgroup>
							<tr>
								<th>사원명</th>
								<td class="formText"><input type="text" name="dataEmpName" value="" MAXBYTE="50"></td>
							</tr>
						</table>						
					</div>
					<div class="btn_area">
						<a href="javascript:clearData();" class="easyui-linkbutton">초기화</a>
						<a href="javascript:saveData();" class="easyui-linkbutton">저장</a>
						<a href="javascript:deleteData();" class="easyui-linkbutton">삭제</a>
					</div>
				</div>
			</div>
		</div>
		
	</div>

	<div data-options="region:'south',border:false" class="layout_south alignL">
		Copyright 2013 Suwon City Facilities Management Corporation. All rights reserved.
		<p class="btn_close" title="닫기" onclick="window.close()"></p>
	</div>
		
</form>
<script type="text/javascript">
//그리드
$('#grid_emp').datagrid({
	rownumbers:true,
    fitColumns: true,
    singleSelect: true,
    fit: true,
    striped: true,
    toolbar:'#tb_emp',
    //pagination: true,
    nowrap: true,
    data:<%=empList%>,
    columns:[[
        {field:'empIdx',fixed:true,width:20,checkbox:true},
      	{field:'empName',title:'사 원 명',fixed:true,width:300,align:'center'}
    ]]
});
function viewTitle(val,rec){
	return '<span title="'+val+'">'+val+'</span>';
}

$('#grid_emp').datagrid({
	onClickRow:function(){
		var row = $('#grid_emp').datagrid('getSelected');
		if (row){
			document.form.dataEmpIdx.value = row.empIdx;
			document.form.dataEmpName.value = row.empName;
		}
	}
}); 
</script>
</body>

</html>